from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.schema import  TextNode
from llama_index.core import Settings, VectorStoreIndex
from llama_index.embeddings.zhipuai import ZhipuAIEmbedding
from llama_index.core.graph_stores import SimplePropertyGraphStore

embed_model = ZhipuAIEmbedding(
    model="embedding-2",
    api_key="f387f5e4837d4e4bba6d267682a957c9.PmPiTw8qVlsI2Oi5"
    # With the `embedding-3` class
    # of models, you can specify the size
    # of the embeddings you want returned.
    # dimensions=1024
)
Settings.embed_model=embed_model

text="""金秋十月，中华人民共和国迎来76周年华诞。每逢国庆，无论身处何地，爱国主义情愫都会引发中华儿女心中的共鸣。
爱国，是人世间最深层、最持久的情感，是每一个中国人的心之所系、情之所归。"""

node = TextNode(text=text, metadata={"title": "金秋十月"})
from llama_index.core.storage.docstore import SimpleDocumentStore
from llama_index.core.storage.index_store import SimpleIndexStore
from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.node_parser import SentenceSplitter
# create storage context using default stores
from llama_index.core import StorageContext, load_index_from_storage
storage_context = StorageContext.from_defaults(
    docstore=SimpleDocumentStore(),
    vector_store=SimpleVectorStore(),
    index_store=SimpleIndexStore(),
)
node001=TextNode(text=text)
nodes=[node, node001]

from llama_index.core.indices.keyword_table.simple_base import (
    GPTSimpleKeywordTableIndex,
    SimpleKeywordTableIndex,
)
vector_index = VectorStoreIndex(nodes, storage_context=storage_context)

vector_index22223q = VectorStoreIndex(nodes, storage_context=storage_context)
# create (or load) docstore and add nodes


# build index
storage_context.index_store.persist("./index_store/index_store.json")
